<template>
   <view class="w h bg-white">
      <view class="padding-top margin-left">
           <button class="cu-btn line-grey round " @click="selectVideoFile">选择文件</button>
           <view class="margin-top-sm">
              <text>文件名称：</text>
              <text>{{file.filename}}</text>
           </view>
           <view class="margin-top-sm">
              <text>文件类型：</text>
              <text>{{file.filetype}}</text>
           </view>
           <view class="margin-top-sm">
              <text>文件大小：</text>
              <text>{{file.filesize}}</text>
           </view>
      </view>
      
   </view>
</template>
<script setup lang="ts">
 import { ref, reactive} from 'vue' 

 const file = reactive<any>({
    filename: '',
    filesize:  null,
    filetype: '',
    filePath: null
 })

 function selectVideoFile(){
    uni.chooseFile({
        count: 1,
        type: 'video',
        success: (res: any) => {
          const tempFilePaths =  res.tempFilePaths
          const tempFiles =  res.tempFiles

          file.filePath = tempFilePaths[0]
          const {name, type, size} = tempFiles[0]        
          file.filename = name
          file.filetype = type
          file.filesize = size
        }
    })
 }

</script>
